#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>

int main()
{
    pid_t pid;

    pid = fork();

    if (pid < 0)
    {
        fprintf(stderr, "fork failed");
        return 1;
    }
    else if (pid == 0)
    {
        printf("这是子进程,PID: %d\n", getpid());
    }
    else
    {
        printf("这是父进程,PID: %d,子进程PID: %d\n", getpid(), pid);
    }

    return 0;
}
